import { computed } from "vue";

export default callBack => {
  const catchData = new Map();
  return (...args) => {
    const argsKey = JSON.stringify(args);
    const catchResult = catchData.get(argsKey);
    if (catchResult) {
      return catchResult;
    } else {
      const result = computed(() => callBack(...args));
      catchData.set(argsKey, result);
      return result;
    }
  };
};
